package com.woniu.util;

import javax.servlet.*;
import java.io.IOException;

/**
 * @author WenXin
 * @version 1.0
 * @description: TODO
 * @date 2022/8/26 16:01
 */
public class TimeCountFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        Filter.super.init(filterConfig);
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
        long start = System.currentTimeMillis();
        filterChain.doFilter(request, response);
        long end = System.currentTimeMillis();
        System.err.println("后端耗时：" + (end - start) + "ms");
    }

    @Override
    public void destroy() {
        Filter.super.destroy();
    }
}
